Quantcast
Channel: Aspose.Pdf Product Family
Viewing all 3131 articles
Browse latest View live

java.awt.HeadlessException

$
0
0

I am getting following Exception when I ran in Linux server,

java.awt.HeadlessException

                at sun.awt.HeadlessToolkit.getScreenSize(HeadlessToolkit.java:261)

                at com.aspose.pdf.internal.p13.z9.m1(Unknown Source)

                at com.aspose.pdf.internal.p13.z47.<init>(Unknown Source)

                at com.aspose.pdf.internal.p212.z15.m1(Unknown Source)

                at com.aspose.pdf.internal.p212.z15.m1(Unknown Source)

                at com.aspose.pdf.internal.p216.z1.m1(Unknown Source)

                at com.aspose.pdf.z72.m1(Unknown Source)

                at com.aspose.pdf.ADocument.m1(Unknown Source)

                at com.aspose.pdf.ADocument.<init>(Unknown Source)

                at com.aspose.pdf.Document.<init>(Unknown Source)

)

 

 

I am trying to convert html to pdf via setting HtmlOptions.

Its work in Windows, but It fails in Linux enviornment.

I even tried to set the page width and height, and also made -Djava.awt.headless to true. also Set the enviornment properties for the same, and it didnt work. Its giving same exception again.

 

 

I am using Latest Aspose PDF 9.7.0 - JDK 1.6 jar

 

I tried to load the Sample HTML file but its not allowing to load in this forum. Can you please help me over this.

 

Thanks,

Jagat


How to print PDF file?

$
0
0
Hi.
I have some PDF document,now I want to print the document,I also need some different parameters for each document printing。

Some document may be select pages to print.
Some document may be select Multiple .

Aspose.pdf cant do that?

Get text for 16.5MB PDF = 2.5GB RAM.....causing crashes.

$
0
0
Hi

Boiled it down to a simple example where trying to get the text from a single PDF uses huge amounts of memory, the problem we have is when running a few in parallel it kills the system or leads to out of memory exceptions, the ratio of 16.5MB to 2.5GB seems crazy

        static void Main(string[] args)
        {
            Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
            pdfLicense.SetLicense(@"C:\Aspose.Pdf.lic");

            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(@"C:\Lenovo Manual.pdf");

            Aspose.Pdf.Text.TextAbsorber textAbsorber = new Aspose.Pdf.Text.TextAbsorber();

            long workingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
            Console.WriteLine(String.Format("BEFORE [Mem:{0}]", workingSet.ToString()));

            doc.Pages.Accept(textAbsorber);

            workingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
            Console.WriteLine(String.Format("AFTER [Mem:{0}]", workingSet.ToString()));
            
            string docText = textAbsorber.Text;
            
            Console.WriteLine("Done");
            Console.ReadLine();
        }

Would appreciate any help on how we can fix this problem.

Cheers

Simon

PDF XFA -> Static/Standard PDF Conversion in Java

$
0
0
Hello,

We are having a problem where XFA PDFs are confusing some of our customers, and they cannot be opened on iOS, etc. So we are wanting to convert these XFA documents into Standard/Static PDFs on the fly, since we don't need them to be dynamic anymore after we generate them, but we just want them to look exactly like the XFA documents do.

It looks like Aspose.PDF for Java can do this, so I downloaded the Trial version to test it out and entered the following code:

import com.aspose.pdf.*; 
public class Main 
public static void main( String[] args ) { //open source PDF documentcom.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("data/StandardTemplate3.pdf");pdfDocument.getForm().setType(FormType.Static);
 pdfDocument.save("data/output.pdf");
System.out.println("Test"); 
 } 
}

But, then I get "Exception in thread "main" class com.aspose.pdf.internal.p235.z9: At most 4 text fragments can be added in evaluation mode."

So, my question is: Will this do what I want it to when not in evaluation mode? Or am I just off-base on thinking of what this is supposed to be doing?

-Thanks!

How to display a pdf file in my android app

$
0
0
Hi

I am new to aspose pdf product and I want to know just how to open an existing pdf file and display it in my app without using adobe reader or other apps.

I need just a simple code; in the java file and in the xml file too.

Thanks

MIMEType and Params for embedded XML

$
0
0
Hello How can I set MIMEType and add Params after embedding an XML in PDF. Both properties are empty. Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("test.pdf"); Aspose.Pdf.FileSpecification fs = new Aspose.Pdf.FileSpecification("any.xml", "My XML File"); pdfDocument.EmbeddedFiles.Add(fs); Thanks Stephan

How to analyze PDFs for regression testing

$
0
0
Hello Aspose,

for testing the PDFs generated with ASPOSE.pdf before I have to analyze them in regression tests for content and formats. Stepping through the forums and documents I did not find a good idea how to reach this.

So I would like to give an example and hope for good ideas how to open and analyze the PDFs accordingly.

I generated a test PDF with the required content as attached.
My test requirement is: "Image is displayed left aligned and has caption below image"
My test idea was to step to chapter 1. and look at the image and its image text.

But I have no idea how to.
Thanks a lot for your support
Regards
Gerd





HTML to PDF bugg?

$
0
0

Hi!

We are using the latest version of Aspose and are trying to convert a HTML page into a PDF.

The HTML page contains a "Table of Content".
The ToC is created using a table with three columns.
The middle column has 100% width and a dotted bottom border.
The first column has "white-space:nowrap" set, since we don't want the text to be wraped.

This all works fine when browsing the HTML but when it get converted to pdf, the first column of text gets wraped.

Is there a way around it ?

Here is my HTML file:


  <table width='100%'>
        <tr>
            <td style='white-space: nowrap'>This is a long header that shouldnt be wraped since im using nowrap</td>
            <td style='border-bottom: 1px dotted black;' width='100%'>&nbsp;</td>
            <td width='30'>XX</td>
        </tr>
        <tr>
            <td colspan='3'>My description about the header</td>
        </tr>
    </table>


HTML -> PDF Flex bug?

$
0
0
Hi!
I read in the documentation, regarding supported CSS features, that flexbox is supported.

When I try to convert a basic html flex box to PDF it does not work. Am i missing something?

Attached codefile should produce 3 columns with 100% width.

Regards
Per

Inline css in string variable filled with html text does not get displayed correctly in PDF.

$
0
0

We have a custom action in SharePoint 2013 on a custom list that leads to a page that generates a pdf via the Aspose.PDF .NET dll (downloaded latest version of Aspose.Total DLL's last week).

In the code behind of the page we gather the info of the item we need and convert it to a pdf.

In SharePoint a rich text multi line field can contain a lot of inline styling. A title can be displayed as<span style="Color:#F000000;font-family:Comic Sans MS;">Title<span>. But when we convert it to the pdf the inline styling of the span is not displayed. It does not have the correct color or font. We need some help on this one.

Below are the most import pieces of the code we use to generate the pdf.

 

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

Aspose.Pdf.Generator.Section section = new Aspose.Pdf.Generator.Section();

string text = SPHttpUtility.HtmlDecode(item[fldText.InternalName].ToString().Replace("&#160;", "<br>"));

string cssBeginText = @"<!DOCTYPE HTML"">

                                       <HTML>

                                       <HEAD>

                                       <LINK REL=StyleSheet HREF=""" + url + @"/_layouts/15/Hubo_CustomAction_Print/MinimalStyling.css"">

                                       </HEAD>

                                       <BODY>";

string cssEndText = @"</BODY></HTML>";

text = cssBeginText + text + cssEndText;

Aspose.Pdf.Generator.Text body = new Aspose.Pdf.Generator.Text(text);

body.TextInfo.FontName = fontBody;

body.IsHtmlTagSupported = true;

body.TextInfo.IsFontEmbedded = true;

body.TextInfo.FontSize = fontziseBody;

section.Paragraphs.Add(body);

               pdf.Sections.Add(section);

               pdf.Save(@"overzicht.pdf", SaveType.OpenInAcrobat, Response);


 

How to merge PDF with Table of Contents?

$
0
0
Hi,

I have a bunch of PDF files that I want to merge into a single one, but at the same time I want to create ToC - one heading per document. Is it possible?

Thank you,
Mariusz

Aspose.Pdf.Text.FontRepository.FindFont Method

$
0
0
When using FindFont does is the font name supplied need to be case sensitive?

Aspose pdf: get text inside drawn rectangle

$
0
0
Hello

We are using the aspose.pdf 9.7.0 to get the highlighted text from annotations, the problem is that in some pdf files when we highlight a specific text, other text is also highlighted (check attached file input.pdf, where we try to highlight the text ET 71140175 but different paragraphs are also highlighted) so we will get incorrect info when getting text from annotations.
We are trying to overcome this problem by using rectangles instead of annotations in order to be able to select the text needed (check attached file inputRect.pdf),
Can you please help us to get the text inside the rectangle using aspose.pdf 9.7.0 and to get the comment made for this rectangle?
or do you have other ideas to overcome the main problem?
Thank you,
Karine

Problem with HOCR

$
0
0
Hi

I'm having an issue trying to embed HOCR data into a PDF

My code looks like this 

    Document doc = new Document("c:/bad/1704-01-2012-017-C003-029.pdf");
            doc.convert(new Document.CallBackGetHocr() {
                @Override
                public String invoke(BufferedImage bi) {
                    try {
                        Tesseract instance = Tesseract.getInstance();  // JNA Interface Mapping
                        instance.setHocr(true);
                        instance.setLanguage("spa");
                        String result = instance.doOCR(bi);
                        
                        return result;
                    } catch (TesseractException ex) {
                        ex.printStackTrace();
                    }

                    return null;
                }
            });

            doc.save("c:/bad/1704-01-2012-017-C003-025_ASPOSE.pdf");

Executing this code (with Tess4j dependencies) doesn't produce a Searchable PDF, Document.CallBackGetHocr sees the image, Tesseract generates the HOCR, but when i save the document, the output is not searchable.

I'm attaching the input, the output and the HOCR generated by Tesseract.
You can avoid using Tesseract by making invoke return the contents of the file "hocr.txt".

I wish you could help me with this problem.

Thanks for your attention

ChangeViewerPreference

$
0
0
I have some PDFs where the User Preference for showing the menu bar had been turned off.

How do I turn back on the menu bar?

I've experimented with the PDFContentEditor.ChangeViewerPreference, but I can't seem to find a enum for turning on the menu bar.

Aspose for Java --> PDF to HTML with embedded CSS

$
0
0
Hello.
I am using Aspose for JAVA version. 
I am having the same issue as this post - I want to convert a PDF to HTML with css data embedded in a <style> tag inside the html file and not as a separated file.

but I am using JAVA and I couldn't find the "PartsEmbeddingModes" property. I get a syntax error that PartsEmbeddingMode and PartsEmbeddingModes cannot be resolved or is not  a field.

My code: (The two bolded properties are not recognized)

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(inStream);
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
options.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedCssOnly;
options.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
pdfDocument.save(mainHtmlFile.getAbsolutePath(), options);


Can you help me please?

Tami










PDF to HTML --&gt; Break each letter to a separate div (JAVA)

$
0
0

Hi.

I used the JAVA Aspose for PDF (version 9.7.1) in order to convert a PDF to html.

My (first) problem is that some of the text is converted to html by separating each character to its own <div >. I think it happen when there is a style change like italic-font. This is a critical issue for me because it affects the search results.

Another issue is that the rest of the text is converted when each line is in its own <div > but each 2-3 words are in a separated <span >.

 

(Note that I used the java-aspose and I got these two issues, but when I used the .Net-aspose the first issue didn't occure, only the second one)

 

I attached a test pdf (copied from Wikipedia).

My JAVA code in order to convert the attached pdf file to html is: 

--------------------------------------------------------------------------------

File mainHtmlFile = createNewHtmlFile();
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(inStream);
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);
options.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
options.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
options.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
pdfDocument.save(mainHtmlFile.getAbsolutePath(), options);

---------------------------------------------------------------------------------

Can you help me to fix these two issues? or at least the first one?

Thanks

Tami

 

The type or namespace name 'Pdf' does not exist in the namespace 'Aspose'

$
0
0
Here is my code.  This two lines of code is compiled fine under VS2010.  But for the VS2013, I could not  make it compiled.



using AsposePdf = Aspose.Pdf;
using AsposeWord = Aspose.Words;


Got the following error:

Error37The type or namespace name 'Pdf' does not exist in the namespace 'Aspose' (are you missing an assembly reference?)

Thanks.

Overlapping Link Annotations

$
0
0
Hi,

I am using Text Absorber to add link annotations, but there are scenarios where I have following texts in the document,

"Internal"
"Internal............"

Now when I add link annotations I get two links to a single word as you can see in the attached picture.

Now what I want 2 things,

1) If link annotation has been added then ignore it
2) I will tell later :)

I am using following code here, Please note, I am receiving data from web services - so no hard coding,

var doc = new Document(@"C:\Users\hannah.Gar\Desktop\output\dummyDocument.pdf");

            var textFragmentAbsorber = new TextFragmentAbsorber("Internal....................");
            doc.Pages.Accept(textFragmentAbsorber);
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

            foreach (TextFragment textFragment in textFragmentCollection)
            {
                Page pagee = textFragment.Page;
                Page destinationPage = doc.Pages[1];

                var link = new LinkAnnotation(pagee, textFragment.Rectangle);
                var border = new Border(link) { Width = 2 };
                link.Border = border;
                link.Action = new GoToAction(destinationPage);

                pagee.Annotations.Add(link);

                var textAnnotation = new FreeTextAnnotation(textFragment.Page, textFragment.Rectangle,
                    new DefaultAppearance(FontRepository.FindFont("TimesNewRoman"), 10, System.Drawing.Color.Black))
                {
                    Border = border
                };
                pagee.Annotations.Add(textAnnotation);
            }

            var textFragmentAbsorber2 = new TextFragmentAbsorber("Internal");
            doc.Pages.Accept(textFragmentAbsorber2);
            TextFragmentCollection textFragmentCollection2 = textFragmentAbsorber2.TextFragments;

            foreach (TextFragment textFragment2 in textFragmentCollection2)
            {
                Page pagee = textFragment2.Page;
                Page destinationPage = doc.Pages[1];

                var link = new LinkAnnotation(pagee, textFragment2.Rectangle);
                var border = new Border(link) { Width = 4 };
                link.Border = border;
                link.Action = new GoToAction(destinationPage);

                pagee.Annotations.Add(link);

                var textAnnotation = new FreeTextAnnotation(textFragment2.Page, textFragment2.Rectangle,
                    new DefaultAppearance(FontRepository.FindFont("TimesNewRoman"), 14, System.Drawing.Color.Gold))
                {
                    Border = border
                };
                pagee.Annotations.Add(textAnnotation);
            }


            doc.Save(@"C:\Users\hannah.Gar\Desktop\output\textabsorber.pdf");


Thanks :) 

Aspose.pdf

$
0
0
Hello,

In the description of Sharepoint .PDF, it is only mentioned that the product is compatible with SharePoint 2010. What about sharePoint 2013?

Thanks,
Viewing all 3131 articles
Browse latest View live