Aspose.PDF gives me an 'out of memory' error on trying to process large PDF file
aspose.pdf TextFragmentAbsorber to use existing form
Embed glyphs into PDF
Is it possible to embed only used glymphs into the PDF?
I searched through the documentation, but only found something like RemoveDuplicatedFonts and RemoveSimilarFontsWithDifferentWidths. That is not what I want.
I want to know whether it is possible to tell aspose to embed only the glyphs that are actually used, instead of the whole font.
The problem I have is that the PDF gets very large when using certain fonts. If I use "NotoSansCJKjp-Regular" font from Google Noto Fonts, the document increases in size with more than 10MB.
The code snippet below demonstrates this issue. There is one table and 2 cells with some text. The result is saved in the attachment: "ResultNoto.pdf".
If I comment out the line of code that specifies usage of "NotoSansCJKjp-Regular", the resulting PDF more than 10MB smaller: "Result.pdf".
The files are attached and the sample code is below:
List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
fontPaths.add("C:\\temp\\Noto-hinted");
com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
List<String> inputStringList = new ArrayList<>();
inputStringList.add("äöüß é ç Здравствуйте 3 df a dad a END");
inputStringList.add("äöüß é ç Здравствуйте 昨夜のコンサートは最高でし adsf dfg END");
com.aspose.pdf.Document doc = new com.aspose.pdf.Document("Blank.pdf");
com.aspose.pdf.Table table = new com.aspose.pdf.Table();
table.getDefaultCellTextState().setFont(com.aspose.pdf.FontRepository.findFont("NotoSansCJKjp-Regular"));
table.setColumnWidths("400");
for (String currentString : inputStringList) {
Row row = table.getRows().add();
row.getCells().add(currentString);
}
I am using aspose.pdf verson 11.8.0
Thank you,
Samuel
Replaced content not reflowing
Hyperlink in HtmlFragment Text
Error while converting html page to pdf
RadioButtonOptionField Crashes when trying to place in Tabel Cell
I am trying to add RadioButtonOptionField to a tabel cell, But it is throwing the NullPointerException. I don't want to mention Rectangle parameter because i need to add it to a table cell than fixing the position using rectangle.
Version: aspose.pdf-16.10.0.jar
Error:
at com.aspose.pdf.Annotation.m1(Unknown Source)
at com.aspose.pdf.WidgetAnnotation.m1(Unknown Source)
at com.aspose.pdf.Field.m1(Unknown Source)
at com.aspose.pdf.Annotation.m1(Unknown Source)
at com.aspose.pdf.RadioButtonField.add(Unknown Source)
Code:
Table table = new Table();
table.setMargin(new MarginInfo(20, 20,10, 0));
table.setColumnWidths("50 50");
pdfPageItem.getParagraphs().add(table);
RadioButtonField radio = new RadioButtonField(pdfPageItem);
RadioButtonOptionField opt1 = new RadioButtonOptionField(); -- > Null exception here
opt1.setOptionName("Test1");
opt1.setName("Test1");
opt1.setCaption(new TextFragment("Test1"));
Row row = table.getRows().add();
Cell cellYesField = row.getCells().add();
cellYesField.getParagraphs().add(opt1);
pdfDoc.getForm().add(radio);
pdfDoc.save("Sample.pdf");
Please let me know how i can add the options to a table cell rather than using fixed coordinates using rectangle.
Thanks,
Leena Robert
How to set ImageFileType for Image
Hi Team,
I am getting image as bytes from database and that bytes may be of a png or jpeg mage.
How can specify the ImageFileType for an Image control in pdf.
Document pdfDoc = new Document();
pdfDoc.getPageInfo().getMargin().setLeft(10);
pdfDoc.getPageInfo().getMargin().setRight(20);
pdfDoc.getPageInfo().getMargin().setTop(10);
pdfDoc.getPageInfo().getMargin().setBottom(10);
pdfDoc.getPages().add();
Image img1 = new Image();
img1.setFixHeight(50);
img1.setFixWidth(50);
ByteArrayInputStream bstream = new ByteArrayInputStream(bytes);
img1.setImageStream(bstream);
pdfPageItem.getParagraphs().add(img1);
pdfDoc.save("Sample.pdf");
Thanks
Leena Robert
How to set background colour of a FreeTextAnnotation
new Pdf.InteractiveFeatures.DefaultAppearance("Arial", fontSize, color); Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation annotation = new Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(page, new Pdf.Rectangle(llx, lly, urx, ury), appearance);
TIA
Dan
Table Page Break (PDF)
Hello!
I am trying to stop Aspose PDF from page breaking in the middle of a table in C# .NET. I have not found any answers that have solved this problem through Google, Stackoverflow, or this forum.
We have a table with two rows that must always be together as they are utilized as a header. These rows are currently being split sometimes when they happen to fall on a page break. I wish to stop this from happening.
I have found the table.isBroken
attribute always returns true and row.isRowBroken
always returns false (from Aspose). This does not help me to stop the page from breaking in the middle of this table.
Here is a link to the post on stackoverflow: http://stackoverflow.com/questions/42079506/do-not-page-break-on-table-in-aspose-pdf-c-sharp-asp-net
Thank you for your time!
PDF Margin info giving me same values always
Not able to flatten form and radio button and place form dynamically
I am having a PDF which have editable and non-editable part.
My requirement is that I should be able to make the editable part non editable depending on a configuration.
I have added controls like CheckboxField, RadioButtonOptionField, TextBoxField.
These controls I have added to a table which suits my requirement.
Is it necessary that I have to add the editable control to a Form?
If I add it to form the control shows up in two place. One in the table where I have placed according to the pdf design and also on the first page as I am adding to pdf.getForm().add(field, 1)
If I don't place the fields in the form I would not be able to flatten the PDF to make it non editable.
I am also not able to add the table to the Form as it allows only field item.
As per requirement I would not be able to place the form in any static location like Rectangle as my data remains dynamic and can grow to any extend.
Please let me know if there is a way to make the form visibility false so that non of my fields are repeated twice, also please let me know if there any work around.
Code:
static void Create() throws FileNotFoundException
{
Booleam isPdfEditable = false;
pdfDoc = new Document();
pdfPageItem = pdfDoc.getPages().add();
pdfPageItem.getParagraphs().add(NonEditableContent()); --- > Implementation not provided in code
pdfPageItem.getParagraphs().add(GetTable());
if(!isPdfEditable)
{
pdfDoc.flatten();
pdfDoc.getForm().flatten();
Field[] fields = pdfDoc.getForm().getFields();
for(Field field : fields)
{
field.flatten();
}
}
pdfDoc.save("Sample.pdf");
}
private static Table GetTable()
{
Table questionTable = new Table();
questionTable.setMargin(pdfDoc.getPageInfo().getMargin());
questionTable.setColumnWidths("20 500");
RadioButtonField rf = new RadioButtonField(pdfDoc);
rf = new RadioButtonField(pdfPageItem);
rf.setPartialName("radio");
Row r2 = questionTable.getRows().add();
Cell c2 = r2.getCells().add();
Cell c3 = r2.getCells().add();
c2.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Top);
c2.setWordWrapped(true);
c3.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Bottom);
c3.setWordWrapped(true);
RadioButtonOptionField opt1 = new RadioButtonOptionField();
opt1.setOptionName("Name");
opt1.setWidth(10);
opt1.setHeight(10);
rf.add(opt1);
pdfDoc.getForm().add(opt1, 1);
RadioButtonOptionField opt2 = new RadioButtonOptionField();
opt2.setOptionName("Name");
opt2.setWidth(10);
opt2.setHeight(10);
rf.add(opt2);
pdfDoc.getForm().add(opt2, 1);
c2.getParagraphs().add(opt1);
c3.getParagraphs().add(opt2);
CheckboxField chk1= new CheckboxField(pdfDoc);
chk1.setPartialName("ch");
chk1.setWidth(10);
chk1.setHeight(10);
Border border = new Border(chk1);
border.setWidth(2);
border.setStyle(BorderStyle.Solid);
chk1.setBorder(border);
chk1.getCharacteristics().setBorder(java.awt.Color.BLACK);
pdfDoc.getForm().add(chk1, 1);
TextBoxField textBoxField1 = new TextBoxField(pdfDoc);
textBoxField1.setPartialName("tb");
textBoxField1.setHeight(30);
textBoxField1.setWidth(500);
textBoxField1.setInLineParagraph(true);
textBoxField1.setMultiline(true);
pdfDoc.getForm().add(textBoxField1, 0);
Row r3 = questionTable.getRows().add();
Cell c4 = r3.getCells().add();
Cell c5 = r3.getCells().add();
c4.getParagraphs().add(chk1);
c5.getParagraphs().add(textBoxField1);
return questionTable;
}
Is relative css possible with Aspose when converting pdf to html?
I have a situation where pdfs needs to be translated to different languages. The process is to first convert it into html and the pass the html as input to translator API. Translator returns the translated html with original html tags intact. Now if the translated text isn't of the same size of text in original language then overlapping happens and the readability is affected. So want to know if relative stylingpossible with Aspose. Attaching picture of position styling generated by Aspose.
Regards,
Amit
Multiple text in fragment
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
PDF signing questions (multiple Digital Signatures (PKI)) PAdES support
Example: A PDF is authored by a third party and signed to authenticate the author. We want to append some additional information then apply our signature. We would like both signatures to be intact, the signature on the original portion of the document and the signature on the whole (outer) document.
iText supports this as it supports PAdES (PDF Advanced Electronic Signatures)