Multiple text in fragment

Hi Team,

I am generating PDF using aspose java api. I like to combine different texts together in the same paragraph. For ex: i have a text followed by ------------------, a line to enter something and again text and a line to enter something. I tried to achieve this by adding fragement and having segments added to fragment. abut i am unable to add line to fragement. Also is there any way to mention font stlying for the entire PDF?


Thanks,
Gomathi R

Hello Gomathi,


Thanks for using our API’s.
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}


I like to combine different texts together in the same paragraph. For ex: i have a text followed by ------------------, a line to enter something and again text and a line to enter something. I tried to achieve this by adding fragement and having segments added to fragment. abut i am unable to add line to fragement.

I will appreciate if you please share your sample code along with output file. It will help us to understand your requirement exactly and address it accordingly.

is there any way to mention font stlying for the entire PDF?

Aspose.Pdf for Java supports the capability to replace text in PDF document. However, sometimes you have a requirement to only replace the font being used inside PDF document. So instead of replacing the text, only font being used is replaced. One of the overloads of TextFragmentAbsorber constructor accepts TextEditOptions object as an argument and we can use RemoveUnusedFonts value from TextEditOptions.FontReplace enumeration to accomplish our requirements.


The following code snippet shows how to replace font inside PDF document. I have also attached the output PDF document for your reference.


Java


String myDir = "/Users/fahadadeel/Downloads/resources/";

// Load existing PDF Document
Document pdf = new Document(myDir + "pdf-sample.pdf");
// Search text fragments and set edit option as remove unused fonts
TextFragmentAbsorber absorber = new TextFragmentAbsorber(new TextEditOptions(TextEditOptions.FontReplace.RemoveUnusedFonts));
// accept the absorber for all the pages
pdf.getPages().accept(absorber);
// traverse through all the TextFragments
TextFragmentCollection textFragmentCollection = absorber.getTextFragments();
for (Iterator iterator = textFragmentCollection.iterator(); iterator.hasNext();) {
TextFragment textFragment = iterator.next();
String fontName = textFragment.getTextState().getFont().getFontName(); textFragment.getTextState().setFont(FontRepository.findFont("Courier New"));
}
// Save the updated document
pdf.save(myDir + "output_test.pdf");

Furthermore if you want to mention default styling for new PDF documents, Aspose.Pdf has a document level defaultTextState property for this purpose.

doc.getPageInfo().setDefaultTextState(textState)

If you still face any issue, please feel free to contact us.

Best Regards,
gomathi.r:
Also is there any way to mention font stlying for the entire PDF?
Hello Gomathi,

Thanks for contacting support.

Adding more to Fahad's comments, there is not specific approach to define font name for whole document but you need to explicitly define the font information for individual TextFragment and TextSegment. The approach shared above is regarding traversing through all TextSegments inside PDF file and then updating the Font information.

Hello Gomathi,

Thanks for your patience.

We have further looked into your requirement for setting font for entire document and in case the document contains TextFragments/TextSegments, the text formatting can be set using following code snippet.

[Java]

com.aspose.pdf.Document pdf1 = new com.aspose.pdf.Document();

com.aspose.pdf.TextState textState = new com.aspose.pdf.TextState();
textState.setForegroundColor(com.aspose.pdf.Color.getGreen());
textState.setFont(FontRepository.findFont("Times New Roman"));
pdf1.getPageInfo().setDefaultTextState(textState);

pdf1.getPages().add();

pdf1.getPages().get_Item(1).getParagraphs().add(new com.aspose.pdf.TextFragment("Hello World in Times New Roman"));
pdf1.getPages().get_Item(1).getParagraphs().add(new com.aspose.pdf.TextFragment("Second Text line.."));

pdf1.save("c:/pdftest/outputresults.pdf");

pdf1.close();

Hi Nayyer,
Thanks for your reply. That helps for adding font to a page.
I have one more issue while generating PDF. I am generating new PDF using lot of float box and table. If one of my float box content extends to next page, how I will know, I need to place my next float box in the next page? Also, in this case, page numbers are not shown properly in footer. It is showing as 1 of 1 always. Also, the content is getting overlapped on footer and header. Can you please help me to solve these issues?

Hello Gomathi,


Thanks for sharing the details.

Can you please share the code snippet, so that we can test the scenario in our environment. We are sorry for this inconvenience.
package com.optum.ecac;
import java.util.;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.springframework.util.Base64Utils;
import com.aspose.pdf.;
import com.aspose.pdf.drawing.Graph;
import com.aspose.pdf.drawing.Line;
import com.aspose.pdf.facades.LineInfo;
import com.aspose.pdf.facades.PdfContentEditor;

public class PDFGenerator {
static Document doc = new Document();
// Add a new page to document object
static Page page=doc.getPages().add();
public static String DocumentationReference = “DOCUMENTATION REFERENCE: “;



public static String Custom_Note =“Clinical user note: “;



public static void main(String[] args) {

PdfConvertor.Initialize();

//Intialize();



ByteArrayOutputStream outStream = null;



// Create a new Document object

doc.getPermissions();

page.setPageSize(595,842);

//doc.getPageInfo().setWidth(612.0);

//doc.getPageInfo().setHeight();



doc.getPageInfo().getMargin().setLeft(10);

doc.getPageInfo().getMargin().setRight(10);

doc.getPageInfo().getMargin().setTop(30);

doc.getPageInfo().getMargin().setBottom(28);



//Page page = doc.getPages().get_Item(1);



//Add background

BackgroundArtifact background = new BackgroundArtifact();

background.setBackgroundColor(java.awt.Color.white);

page.getArtifacts().add(background);

HeaderInformation data=createHeaderInformation();

//header information

addHeaderTable(doc,data);

//Dear doctor section

addDearDoctorSection(doc);

addSystemClinicalIndicatorsSection(doc,CreateIndicatorInfo(false));



addAttestionSection(doc);

addHeader(doc,data);

addFooter(doc);



outStream = new ByteArrayOutputStream();

doc.save(outStream, SaveFormat.Pdf);

byte[] fbs = outStream.toByteArray();

String base64=Base64Utils.encodeToString(fbs);

// Save the document

doc.save(“C:/Users/gramam2/GeneratedPDF/” + “Sample.pdf” );

System.out.println(“hello”);

System.out.printf(”\n ArtBox : Height = " + page.getArtBox().getHeight() + “, Width = " + page.getArtBox().getWidth() + “, LLX = " + page.getArtBox().getLLX() + “, LLY = " + page.getArtBox().getLLY() + “, URX = " + page.getArtBox().getURX() + “, URY = " + page.getArtBox().getURY());

System.out.printf(”\n BleedBox : Height = " + page.getBleedBox().getHeight() + “, Width = " + page.getBleedBox().getWidth() + “, LLX = " + page.getBleedBox().getLLX() + “, LLY = " + page.getBleedBox().getLLY() + “, URX = " + page.getBleedBox().getURX() + “, URY = " + page.getBleedBox().getURY());

System.out.printf(”\n CropBox : Height = " + page.getCropBox().getHeight() + “, Width = " + page.getCropBox().getWidth() + “, LLX = " + page.getCropBox().getLLX() + “, LLY = " + page.getCropBox().getLLY() + “, URX = " + page.getCropBox().getURX() + “, URY = " + page.getCropBox().getURY());

System.out.printf(”\n MediaBox : Height = " + page.getMediaBox().getHeight() + “, Width = " + page.getMediaBox().getWidth() + “, LLX = " + page.getMediaBox().getLLX() + “, LLY = " + page.getMediaBox().getLLY() + “, URX = " + page.getMediaBox().getURX() + “, URY = " + page.getMediaBox().getURY());

System.out.printf(”\n TrimBox : Height = " + page.getTrimBox().getHeight() + “, Width = " + page.getTrimBox().getWidth() + “, LLX = " + page.getTrimBox().getLLX() + “, LLY = " + page.getTrimBox().getLLY() + “, URX = " + page.getTrimBox().getURX() + “, URY = " + page.getTrimBox().getURY());

System.out.printf(”\n Rect : Height = " + page.getRect().getHeight() + “, Width = " + page.getRect().getWidth() + “, LLX = " + page.getRect().getLLX() + “, LLY = " + page.getRect().getLLY() + “, URX = " + page.getRect().getURX() + “, URY = " + page.getRect().getURY());

System.out.printf(”\n Page Number :- " + page.getNumber());

System.out.println(“perm”+doc.getPermissions());

}

private static HeaderInformation createHeaderInformation() {



HeaderInformation header=new HeaderInformation();

header.PhysicianName=“Patient name”;

header.Account=“12345678”;

header.AdmitDate=“12/3/2015”;

header.CreatedBy=“CDITester1”;

header.DischargeDate=“12/3/2015”;

header.DOB=“12/3/2015”;

header.Facility=“UPMC”;

header.Gender=“female”;

header.MRN=“456768”;



return header;



}

private static void addHeader(Document doc,HeaderInformation headerData )

{

HeaderFooter header=new HeaderFooter();

TextFragment headerInfo=new TextFragment();

headerInfo.getTextState().setBackgroundColor(Color.getLightGray());



String s=“Patient Name: “+headerData.PhysicianName;

String a=“Account: “+headerData.Account;

TextSegment name=new TextSegment(s);



TextSegment acc=new TextSegment(a);

headerInfo.getSegments().add(name);

headerInfo.getSegments().add(acc);

Table table = new Table();

// Set the table border color as LightGray

table.setMargin(new MarginInfo(3,3,3,3));

// set the border for table cells

table.setDefaultCellBorder(new BorderInfo(BorderSide.Top, .7f,Color.getBlack()));



// Set with column widths of the table

table.setColumnWidths(“130 130”);



table.setBackgroundColor(Color.getLightGray());

table.getDefaultCellTextState().setFont(FontRepository.findFont(“Calibri”));

table.getDefaultCellTextState().setFontSize(12);

table.getDefaultCellTextState().setForegroundColor(Color.getBlack());

table.setBorder(new BorderInfo(BorderSide.Top,.7f,Color.getBlack()));

table.setBorder(new BorderInfo(BorderSide.Bottom, .7f,Color.getBlack()));

//table.setDefaultCellBorder(new BorderInfo(BorderSide.Top, .7f,Color.getBlack()));

//table.setDefaultCellBorder(new BorderInfo(BorderSide.Bottom, .7f,Color.getBlack()));

table.setAlignment(com.aspose.pdf.HorizontalAlignment.Left);

MarginInfo margin = new MarginInfo();

margin.setLeft(3);

margin.setRight(4);

margin.setTop(5);

margin.setBottom(5);

// Set the default cell padding to the MarginInfo object

table.setDefaultCellPadding(margin);

// add row to table

Row row = table.getRows().add();



// add table cells

row.getCells().add(“Patient Name:”).setAlignment(com.aspose.pdf.HorizontalAlignment.Left);

row.getCells().add(headerData.PhysicianName).setAlignment(com.aspose.pdf.HorizontalAlignment.Left);



row.getCells().add(“Account:”).setAlignment(1);

row.getCells().add(headerData.Account).setAlignment(com.aspose.pdf.HorizontalAlignment.Left);

header.getParagraphs().add(table);

header.getMargin().setLeft(0);



for (int cnt = 1; cnt
{

if(cnt!=1)

doc.getPages().get_Item(cnt).setHeader(header);



}

}

private static void addFooter(Document doc)

{



HeaderFooter footer=new HeaderFooter();

//create image stamp



ImageStamp imageStamp = new ImageStamp(“C:/Work/SampleJavaProject/optum-logo1.png”);



imageStamp.setHeight(50);



imageStamp.setWidth( 50);



imageStamp.setHorizontalAlignment(com.aspose.pdf.HorizontalAlignment.Left);



//create footer



TextStamp textStamp = new TextStamp(“Continue to next page…”);



//set properties of the stamp



textStamp.setBottomMargin(10);



textStamp.setHorizontalAlignment(com.aspose.pdf.HorizontalAlignment.Center);



textStamp.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Bottom);

textStamp.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Italic);





//create page number stamp



PageNumberStamp pageNumberStamp = new PageNumberStamp();



//whether the stamp is background



pageNumberStamp.setBackground(false);



pageNumberStamp.setFormat(“Page # of " + doc.getPages().size());



pageNumberStamp.setBottomMargin(10);



pageNumberStamp.setHorizontalAlignment(com.aspose.pdf.HorizontalAlignment.Right);



pageNumberStamp.setStartingNumber(1);

for (int cnt = 1; cnt <= doc.getPages().size(); cnt++)

{

doc.getPages().get_Item(cnt).addStamp(imageStamp);

if(cnt!=doc.getPages().size())

doc.getPages().get_Item(cnt).addStamp(textStamp);

//add stamp to particular page

doc.getPages().get_Item(cnt).addStamp(pageNumberStamp);

}

}

private static void addDearDoctorSection(Document doc)

{

//Page page = doc.getPages().get_Item(1);

FloatingBox aBox = new FloatingBox();

//aBox.setMargin(new MarginInfo(3,3,3,3));

// Set left position for FloatingBox

//aBox.setLeft(6);

// Set Top position for FloatingBox

//aBox.setTop(120);

// Set the vertical alignment for FloatingBox

//aBox.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Top);

// Set Horizontal alignment for FloatingBox

//aBox.setHorizontalAlignment(com.aspose.pdf.HorizontalAlignment.Left);

// Add text fragment to paragraphs collection of FloatingBox

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(“Dear Physician name”));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(“Testing”));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(“hello”));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(””));

aBox.getParagraphs().add(new TextFragment(””));

// Set border for FloatingBox

//aBox.setBorder(new BorderInfo(15 /BorderSide.Box/));

// Set background color for FloatingBox

//aBox.setBackgroundColor(com.aspose.pdf.Color.getw());

// Add FloatingBox to paragraphs collection of page object

page.getParagraphs().add(aBox);





}

private static void addSystemClinicalIndicatorsSection(Document doc,List indicatorInfo)

{

//Page page = doc.getPages().get_Item(1);

FloatingBox floatBox = new FloatingBox();

floatBox.setMargin(page.getPageInfo().getMargin());

floatBox.setWidth(page.getPageInfo().getWidth());

page.getParagraphs().add(floatBox);

TextFragment seg=new TextFragment(“Clinical Indicators”);

seg.getTextState().setFont(FontRepository.findFont(“Calibri”));

seg.getTextState().setFontSize(12);

seg.getTextState().setForegroundColor(Color.getBlack());

floatBox.getParagraphs().add(seg);

floatBox.getParagraphs().add(new TextFragment(””));



if (indicatorInfo == null)

;

Heading heading;

for(PqfIndicatorInfo indicator : indicatorInfo)

{

/if (GenericHelper.isValid(indicator.getIndicatorType()) &&

GenericHelper.isValid(indicator.getIndicatorLabel())

&& GenericHelper.isValid(indicator.getDocumentName()) && !GenericHelper.isValid(indicator.getDateService()))



continue;/

StringBuilder s=new StringBuilder();

heading= new Heading(1);

heading.setInList(true);

heading.setStartNumber(1);

heading.setUserLabel(new TextSegment(“Bullet1”));

//heading.setText(“MENTION_OF:Anemia:Statements Post op anemia secondary to surgical blood loss (Ortho-Progress,04/02/2013 08:28:00 AM)”);

heading.setStyle(NumberingStyle.NumeralsRomanUppercase);



heading.setAutoSequence(true);





s.append(indicator.getIndicatorType());



if (isValid(indicator.getIndicatorLabel()) ){

s.append(”: “);

s.append(indicator.getIndicatorLabel().trim());

}



if (isValid(indicator.getHiliteText())){

s.append(”: “);

s.append(indicator.getHiliteText());}



if (isValid(indicator.getDocumentName()) || isValid(indicator.getDateService()))

{

s.append(indicator.getDocumentName().trim());

s.append(” [”+indicator.getDateService()+”]”);

s.append(System.getProperty(“line.separator”));

s.append(System.getProperty(“line.separator”));

}

heading.setText(s.toString());

floatBox.getParagraphs().add(heading);

floatBox.getParagraphs().add(new TextFragment(””));







}

addUserClinicalIndicatorsSection(floatBox, CreateIndicatorInfo(true), “CustomerNote”);



Graph graph = new Graph((float)floatBox.getWidth(),30);

floatBox.getParagraphs().add(graph);

// create first line object starting from Lower-Left to Top-Right corner of page

float[] posArr = new float[]{(float) floatBox.getLeft(),0,(float)floatBox.getWidth(),0};



Line line = new Line(posArr);

line.getGraphInfo().setColor(Color.getBlack());

line.getGraphInfo().setLineWidth(3f);

// add line to shapes collection of Graph object

graph.getShapes().add(line);



page.getParagraphs().add(floatBox);

//page.getParagraphs().add(graph);



}

private static void addUserClinicalIndicatorsSection(FloatingBox fbox,List indicatorData,String customNote)

{

StringBuilder indicatorDoc;

Heading heading;





if (indicatorData != null)

{



for(PqfIndicatorInfo indicator :indicatorData)

{

indicatorDoc = new StringBuilder();

heading= new Heading(1);

heading.setInList(true);

heading.setStartNumber(1);

//heading.setText(“MENTION_OF:Anemia:Statements Post op anemia secondary to surgical blood loss (Ortho-Progress,04/02/2013 08:28:00 AM)”);

heading.setStyle(NumberingStyle.NumeralsRomanUppercase);



heading.setAutoSequence(true);

indicatorDoc.append(DocumentationReference);

indicatorDoc.append(indicator.getHiliteText());

if (isValid(indicator.getDocumentName()) || isValid(indicator.getDateService()))

{

indicatorDoc.append(indicator.getDocumentName().trim()+” “);



indicatorDoc.append(” [”+indicator.getDateService()+” ]”);

indicatorDoc.append(System.getProperty(“line.separator”));

indicatorDoc.append(System.getProperty(“line.separator”));

}

heading.setText(indicatorDoc.toString());

fbox.getParagraphs().add(heading);

fbox.getParagraphs().add(new TextFragment(””));

}

}



if(customNote!=null && !customNote.equals(””))

{

TextFragment customText=new TextFragment(Custom_Note);

TextSegment segment=new TextSegment(customNote);

customText.getSegments().add(segment);

fbox.getParagraphs().add(customText);

fbox.getParagraphs().add(new TextFragment(""));

}

}

public static Boolean isValid(Object… objects)

{



Boolean isValid = true;



if (objects == null)

{

isValid = false;

}

else

{

for (Object obj : objects)

{

if (obj != null && obj instanceof String)

{

String strObj = (String) obj;

if (strObj.length() <= 0)

{

isValid = false;

break;

}

}

else

{

if (obj == null)

{

isValid = false;

break;

}

}

}

}



return isValid;

}

private static void addHeaderTable(Document doc,HeaderInformation headerData)

{

Table table = new Table();

// Set the table border color as LightGray

table.setMargin(new MarginInfo(3,3,3,3));

// set the border for table cells

table.setDefaultCellBorder(new BorderInfo(BorderSide.Bottom, .7f,Color.getDarkGray()));



// Set with column widths of the table

table.setColumnWidths(“180 130”);



table.setBackgroundColor(Color.getLightGray());

table.getDefaultCellTextState().setFont(FontRepository.findFont(“Calibri”));

table.getDefaultCellTextState().setFontSize(12);

table.getDefaultCellTextState().setForegroundColor(Color.getBlack());

MarginInfo margin = new MarginInfo();

margin.setLeft(3);

margin.setRight(4);

margin.setTop(5);

margin.setBottom(5);

// Set the default cell padding to the MarginInfo object

table.setDefaultCellPadding(margin);

// add row to table

Row row = table.getRows().add();



// add table cells

row.getCells().add(“Patient Name:”).setAlignment(1);

row.getCells().add(headerData.PhysicianName).setAlignment(3);



row.getCells().add(“Admit Date:”).setAlignment(1);

row.getCells().add(headerData.AdmitDate).setAlignment(3);



Row row2 = table.getRows().add();

// add table cells

row2.getCells().add(“Gender:”).setAlignment(1);



row2.getCells().add(headerData.Gender).setAlignment(3);

row2.getCells().add(“Discharge Date:”).setAlignment(1);



row2.getCells().add(headerData.DischargeDate).setAlignment(3);



Row row3 = table.getRows().add();

// add table cells

row3.getCells().add(“DOB:”).setAlignment(1);



row3.getCells().add(headerData.DOB).setAlignment(3);

row3.getCells().add(“Facility:”).setAlignment(1);



row3.getCells().add(headerData.Facility).setAlignment(3);



Row row4 = table.getRows().add();

// add table cells

row4.getCells().add(“Account:”).setAlignment(1);



row4.getCells().add(headerData.Account).setAlignment(3);

row4.getCells().add(“Created By:”).setAlignment(1);



row4.getCells().add(headerData.CreatedBy).setAlignment(3);



Row row5 = table.getRows().add();

// add table cells

row5.getCells().add(“MRN:”).setAlignment(1);



row5.getCells().add(headerData.MRN).setAlignment(3);





// Add table object to first page of input document

page.getParagraphs().add(table);



}

private static List CreateIndicatorInfo(boolean isUserref)

{



List list=new ArrayList();

List userList=new ArrayList();

Object hilite=new Object();

if(!isUserref)

{

PqfIndicatorInfo indicator=new PqfIndicatorInfo();

indicator.setIndicatorType(“MEDICATION ORDERED”);

indicator.setIndicatorLabel(“IV lasix”);

indicator.setDocumentName(“ID-Consult”);

indicator.setDateService(new Date());

hilite=" [4/06 02:20] furosemide 80mg IV ONCE [4/06 00:37] pneumococcal 23-valent vaccine (pneumococcal 23-valent vaccine injectable soln) 0.5mL IM ONCE [4/06 00:33] vancomycin 1,500mg IVPB ONCE Future Medications (Starting 4/06 14:00) albuterol-ipratropium (DuoNeb 3 mg-0.5 mg/3 ml inhalation soln) 3mL Aerosol Q6HRSWA (Starting 4/07 23:00) azithromycin 500mg By Mouth Daily (Starting 4/07 09:00) furosemide (Lasix) 80mg By Mouth Daily";

indicator.setHiliteText(hilite);



PqfIndicatorInfo indicator1=new PqfIndicatorInfo();

indicator1.setIndicatorType(“RADIOLOGY RESULT”);

indicator1.setIndicatorLabel(“Pulmonary finding”);

indicator1.setDocumentName(“Radiology Reports”);

hilite=“c enlargement. The left IJ dialysis catheter tip is in lower SVC.There is persistent pulmonary edema wit”;

indicator1.setHiliteText(hilite);

indicator1.setDateService(new Date());



PqfIndicatorInfo indicator2=new PqfIndicatorInfo();

indicator2.setIndicatorType(“MEDICATION ORDERED”);

indicator2.setIndicatorLabel(“IV lasix”);

indicator2.setDocumentName(“ID-Consult”);

indicator2.setDateService(new Date());



hilite=" [4/06 02:20] furosemide 80mg IV ONCE [4/06 00:37] pneumococcal 23-valent vaccine (pneumococcal 23-valent vaccine injectable soln) 0.5mL IM ONCE [4/06 00:33] vancomycin 1,500mg IVPB ONCE Future Medications (Starting 4/06 14:00) albuterol-ipratropium (DuoNeb 3 mg-0.5 mg/3 ml inhalation soln) 3mL Aerosol Q6HRSWA (Starting 4/07 23:00) azithromycin 500mg By Mouth Daily (Starting 4/07 09:00) furosemide (Lasix) 80mg By Mouth Daily";

indicator2.setHiliteText(hilite);





PqfIndicatorInfo indicator3=new PqfIndicatorInfo();

indicator3.setIndicatorType(“MEDICATION ORDERED”);

indicator3.setIndicatorLabel(“IV lasix”);

indicator3.setDocumentName(“ID-Consult”);

indicator3.setDateService(new Date());

hilite=" [4/06 02:20] furosemide 80mg IV ONCE [4/06 00:37] pneumococcal 23-valent vaccine (pneumococcal 23-valent vaccine injectable soln) 0.5mL IM ONCE [4/06 00:33] vancomycin 1,500mg IVPB ONCE Future Medications (Starting 4/06 14:00) albuterol-ipratropium (DuoNeb 3 mg-0.5 mg/3 ml inhalation soln) 3mL Aerosol Q6HRSWA (Starting 4/07 23:00) azithromycin 500mg By Mouth Daily (Starting 4/07 09:00) furosemide (Lasix) 80mg By Mouth Daily";

indicator3.setHiliteText(hilite);





list.add(indicator);

list.add(indicator1);

list.add(indicator2);

list.add(indicator3);

list.add(indicator);

list.add(indicator1);

list.add(indicator2);

return list;

}

else

{

PqfIndicatorInfo indicator=new PqfIndicatorInfo();

indicator.setIndicatorType("");

indicator.setIndicatorLabel("");

indicator.setDocumentName(“Lab Results”);

indicator.setDateService(new Date());

hilite=“Magnesium(Mg) 04/10/2013 07:14 AM Magnesium(Mg) 1.7 mg/dL 1.6-2.3 FINAL”;

indicator.setHiliteText(hilite);

userList.add(indicator);



PqfIndicatorInfo indicator2=new PqfIndicatorInfo();

indicator2.setIndicatorType("");

indicator2.setIndicatorLabel("");

indicator2.setDocumentName(“Lab Results”);

indicator2.setDateService(new Date());

hilite=“Magnesium(Mg) 04/10/2013 07:14 AM Magnesium(Mg) 1.7 mg/dL 1.6-2.3 FINAL”;

indicator2.setHiliteText(hilite);

userList.add(indicator2);



return userList;

}



}

private static void formatPhysicianSignature(Document doc)

{



}

private static void addAttestionSection(Document doc)



{

Page page=doc.getPages().add();

//Page page = doc.getPages().get_Item(1);



FloatingBox floatBox = new FloatingBox();

floatBox.setMargin(page.getPageInfo().getMargin());

floatBox.setWidth(page.getPageInfo().getWidth());



TextFragment seg=new TextFragment(“Attestion Text In Query”);

seg.getTextState().setFont(FontRepository.findFont(“Calibri”));

seg.getTextState().setFontSize(12);

seg.getTextState().setForegroundColor(Color.getBlack());





TextFragment phy=new TextFragment(“Printed query instructions”);

phy.getTextState().setFont(FontRepository.findFont(“Calibri”));

phy.getTextState().setFontSize(12);

phy.getTextState().setForegroundColor(Color.getBlack());



floatBox.getParagraphs().add(seg);

floatBox.getParagraphs().add(new TextFragment(""));

floatBox.getParagraphs().add(new TextFragment(""));

floatBox.getParagraphs().add(phy);

floatBox.getParagraphs().add(new TextFragment(""));

floatBox.getParagraphs().add(new TextFragment(""));





TextFragment phySignature=new TextFragment("");

TextSegment phyName=new TextSegment(“Physician Name (Printed) :”);

phyName.getTextState().setFont(FontRepository.findFont(“Calibri”));

phyName.getTextState().setFontSize(10);

phyName.getTextState().setForegroundColor(Color.getBlack());

phyName.getTextState().setFontStyle(2);



TextSegment phyNameline= new TextSegment("----------------------------------------------------------------------------------------------------------------------------------------------");



phySignature.getSegments().add(phyName);

phySignature.getSegments().add(phyNameline);



// floatBox.getParagraphs().add(phyName);

/* Graph graph = new Graph((float)floatBox.getWidth(),30);

floatBox.getParagraphs().add(graph);

// create first line object starting from Lower-Left to Top-Right corner of page

float[] posArr = new float[]{(float) floatBox.getLeft(),0,100,0};



Line line = new Line(posArr);

line.getGraphInfo().setColor(Color.getBlack());



line.getGraphInfo().setLineWidth(0.4f);

// add line to shapes collection of Graph object

graph.getShapes().add(line);*/

phySignature.getSegments().add(new TextSegment(""));

phySignature.getSegments().add(new TextSegment(""));



TextSegment sign=new TextSegment(“Signed by :”);

sign.getTextState().setFont(FontRepository.findFont(“Calibri”));

sign.getTextState().setFontSize(10);

sign.getTextState().setForegroundColor(Color.getBlack());

phySignature.getSegments().add(sign);

TextSegment phySignLine= new TextSegment("---------------------------------------------------------------------------------------------------------");

phySignature.getSegments().add(phyName);

phySignature.getSegments().add(phyNameline);



phySignature.getSegments().add(new TextSegment(""));





TextSegment signdate=new TextSegment(“Signed on :”);

signdate.getTextState().setFont(FontRepository.findFont(“Calibri”));

signdate.getTextState().setFontSize(10);

signdate.getTextState().setForegroundColor(Color.getBlack());

signdate.getTextState().setFontStyle(2);

phySignature.getSegments().add(phySignLine);

phySignature.getSegments().add(signdate);

phySignature.getSegments().add(phySignLine);

phySignature.getSegments().add(new TextSegment(""));

phySignature.getSegments().add(new TextSegment(""));



floatBox.getParagraphs().add(phySignature);

page.getParagraphs().add(floatBox);

}



}

Hi ,
Any reply on this? Can you please check this quickly. I am trying a POC and need to wrap it up qucikly for deciding on the approach.


thanks,
Gomathi R

Hello Gomathi,


Thanks for sharing the code snippet.

I have tried replicating the issue but I am afraid there are some classes and methods which are not defined in the code snippet i.e. HeaderInformation, PqfIndicatorInfo, CreateIndicatorIfo etc. Can you please again try sharing the code snippet which can help us in reproducing the issue in our environment. We are sorry for this delay and inconvenience.

Hi CodeWarrior,

I have uploaded all the necessary files along with the main file PDFGenerator, where everything is getting called.Please try it and let me know the solution for this.


Thanks,
Gomathi R

Hello Gomathi,


Thanks for sharing the code snippet.

We are working on replicating the issue based on recently shared code and will keep you updated with our findings.

Hello Gomathi,


Thanks for your patience.

I have tested the scenario and have managed to reproduce the FloatingBox flowing to subsequent pages issue. I have also observed that FloatingBox contents are overlapping Header and Footer section. However, as per my observations, the page number information is properly appearing (for your reference, I have also attached the output generated over my end).

Now concerning to above stated issues, I have logged it as PDFJAVA-36485 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Hi,

I have attached the pdf generated through the above code and you can see page1 of 1 in first page and nothing in the second page. Page numbers are generated and shown pnly for the pages created using doc.getpages.add(). Can you attach the pdf generated by you.



Thanks,

Gomathi R

Hello Gomathi,


Thanks for the feedback.

In my earlier attempt, I also managed to notice that page number was not appearing on second page but it was rendered on page 3 where information appeared as Page 2 of 2. Meanwhile I have also associated this information with earlier reported issue and product team will consider this point during the resolution of this problem.

For your reference, I have also attached the output generated over my end.

HI Nayyer,
Any update on whent this issue will be resolved. Is there any work around to get page numbers in the pages? This is urgent for us.

Thanks,
Gomathi R

Hello Gomathi,


Thanks for your patience.

As we recently have noticed earlier reported issue, so its pending for review and is not yet resolved. However the product team will surely consider investigating/fixing it as per development schedule and as soon as we have some definite updates regarding its resolution, we will let you know. Please be patient and spare us little time. We are sorry for this delay and inconvenience.