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

Security settings not applied properly with Aspose.Pdf.Kit

$
0
0

Hello,

I have a problem while setting document security restrictions.

I'm using Aspose.Pdf.Kit to encrypt an existing document with specified security settings. Apparently code compiles and runs successfully but when I open the document it shows no controls to modify/create annotations.

I'm attaching both input (test.pdf) and output files (testoutput.pdf). Here are the passwords for testoutput.pdf:

Document Open Password: opass
Permissions Password: upass

I've tried to use both user password and master password to open the document but again these controls (create annotations) are not visible.

Am I missing something?

Thanks in advance for any help.

Regards,

Anis Ahmad


Issues using HtmlInfo.ExternalResourcesBasePath for CSS

$
0
0
As the subject says, I'm having issues using HtmlInfo.ExternalResourcesBasePath for CSS links. The value I'm applying to that property is working when I apply it to HtmlInfo.ImgUrl.

So, imagine the following:

var basePath = "http://domain";
var pdf = new Pdf {
       HtmlInfo = {
             ImgUrl = basePath,
             ExternalResourcesBasePath = basePath,
       }
};

var section = pdf.Sections.Add();
var text = new Text(section, htmlString) {
        IsHtmlTagSupported = true,
        IsHtml5Supported = true // tried with and without this
};
section.Paragraphs.Add(text);

The HTML I'm using to create the PDF has the following element in the <head> tag:
<link rel="stylesheet" type="text/css" href="/Content/bootstrap.css" />

...and the following element in the <body> tag:
<img src="/Content/images/logo.png" alt="The logo image" />

When I create a PDF, the image is properly found and loaded, but the CSS is NOT applied. If I view the page itself in a browser (without converting it to a PDF), the CSS IS applied. 

I should also note that I've tried stripping "bootstrap.css" down to a couple simple styles to make sure something unsupported wasn't breaking the use of the stylesheet, and it still didn't work.

Am I missing something? Any direction or help would be greatly appreciated!

EDIT: I wrote this based on suggestions found on this page

document.optimizeresources(optVals) throwing out of memory exception

$
0
0
I am using the below code to optimize (shrink) existing large PDF files in VS2012 using vb.net:

        Dim aspDoc As New Aspose.Pdf.Document(strFN)
        Dim optVals As New Aspose.Pdf.Document.OptimizationOptions

        optVals.CompressImages = True
        optVals.ImageQuality = 22
        optVals.RemoveUnusedObjects = True
        optVals.RemoveUnusedStreams = True
        optVals.LinkDuplcateStreams = True
        aspDoc.OptimizeSize = True
        Try
            aspDoc.OptimizeResources(optVals)
        Catch ex As Exception
            MsgBox("Error optimizing resources!", MsgBoxStyle.Exclamation, "")
        End Try

        aspDoc.Save(strFN)

        aspDoc.Dispose()
        GC.Collect()
        aspDoc = Nothing
        GC.Collect()

It works just fine on the 1st PDF file, shrinks down from 50+ MB to 5 MB but throws an OUT OF MEMORY exception on any subsequent attempts on other PDF files of the same magnitude during the same run-time session. So only the 1st large PDF file gets optimized without error. See below error:



When I check performance in task manager it shows 5.38 GIG used out of 8 GIG total usuable memory. Why?

When a license is issued message "Evaluation Only"

$
0
0
Hi! 
I work with the package Aspose.Pdf,  license orderID 130801102820 . In the formation of the document a message "Evaluation Only"
What could be the problem?

package aspose.pdf.new-4.0.0


Rotation

$
0
0
Hi,

I have a pdf which had its page rotated 90 degrees before any content was added. 
The original content was added to the page using no rotation.

Now, if I use Aspose.pdf to add a paragraph(table), then the text is 90 degrees rotated (like the page). Is it possible to add new content with different rotation than the page?

Thanks,
BerntRune

Aspose.Pdf with Spring Jars tomcat

$
0
0
Hi team,

How does Aspose.Pdf work with Spring jars?

Normally When I start my server it takes around 10 secs time

I just put spring-web-3.2.4.RELEASE.jar in my tomcat which has aspose-pdf-9.3.1-jdk16.jar as well. In this case it takes 2min 30secs.

If I remove either spring jar or aspose.pdf jar it takes 10 secs only

Why is it taking such a huge bump of time (from 10sec to 150 sec) when I put both jars and start server?

Thanks,
Tvk Reddy

Paragraph Indenting with IsFirstParagraph and IsKeptWithNext

$
0
0

Hi

I am using Aspose PDF generator v8.5, using the XML method, and I am experiencing an odd problem with paragraph indenting under certain circumstances.

The contributing factors seem to be:

  1. Set the Section PageGutterSize and PageGutterPlacement attributes.
  2. Include content that runs to a second page (either by manual page break, or simply overflowing the first)
  3. On the second page include one or more paragraphs (Text) with the IsKeptWithNext attribute set to true

The problem manifests in the paragraph immediately following the paragraph with the IsKeptWithNext property rendering indented from the left margin. Not even manually setting the MarginLeft attribute will bring the paragraph back into line.

Am I doing something wrong, or is this an obscure bug in the PDF generator? I have attached an XML file that demonstrates the issue.

The C# code I use to transform the XML into PDF is as follows:

				LoadAsposeLicense();Pdf pdf = new Pdf();
				pdf.BindXML(xmlFileName, null);Document doc = new Document(pdf);
				doc.Save(pdfFileName);
				OpenDocument(pdfFileName);

UPDATE: I forgot to mention, I'm using Visual Studio 2010, .NET 4.0.

Thanks in advance for any insight anyone can offer.

Chris Fairall.

TextFragmentAbsorber.TextFragments not functioning properly

$
0
0
Hi,
We are using Aspose PDF for .Net evaluation version and we are facing few issues.  We are trying to change the foreground color of text in a pdf using position and for some text the color is not changing properly.  For those text, the TextFragments count is returning as 0.  Can you please look into the below code and help us to solve the issue.

Document pdfDocument = new Document(dataDir + "Festive Schedule.pdf");
 List<LocationRepository> repository = new List<LocationRepository>();
              LocationRepository locationRepository;
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@".", new TextSearchOptions(true));
      
 for (int i = 1; i <= pdfDocument.Pages.Count; i++)
              {
                  pdfDocument.Pages[i].Accept(textFragmentAbsorber);
                  //get the extracted text fragments
                  textFragmentCollection = textFragmentAbsorber.TextFragments;
                  foreach (TextFragment textFragment in textFragmentCollection)
                  {
                      foreach (TextSegment textSegment in textFragment.Segments)
                      {
                          locationRepository = new LocationRepository();
                          locationRepository.letter = textSegment.Text;
                          locationRepository.LLX = (float)textSegment.Rectangle.LLX;
                          locationRepository.LLY = (float)textSegment.Rectangle.LLY;
                          locationRepository.URX = (float)textSegment.Rectangle.URX;
                          locationRepository.URY = (float)textSegment.Rectangle.URY;
                          repository.Add(locationRepository);
}
}

for (int i = 0; i < repository.Count; i++)
            {

                TextFragmentAbsorber absorber = new TextFragmentAbsorber(repository[i].letter);
absorber.TextSearchOptions.LimitToPageBounds = true;
                absorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle((float)repository[i].LLX, (float)repository[i].LLY, (float)repository[i].URX, (float)repository[i].URY);
  pdfDocument.Pages.Accept(absorber);
 TextFragmentCollection textFragmentCollection = absorber.TextFragments;
    foreach (TextFragment textFragment in textFragmentCollection)
                 {
                     foreach (TextSegment textSegment in textFragment.Segments)
                     {              
                         textSegment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
                     }
                 }

Regards,
Sreevidya

How to reduce size of a pdf file through aspose api?

$
0
0
Hi,

    I am creating an app in window 8 that can reduce the size of a pdf file. Is there any aspose api available that can do it for me. I am already using aspose api's for converting pdf to word and images and also other api's like split pdf, move pdf pages etc. Is there also any aspose api available that can reduce the size of a file? If yes then please provide me it with c# sample code.


   Thanks....

    

Unable to extract images from PDF

$
0
0
hi, for a pdf the aspose pdf library (version 4.2.1) is unable to extract the images. As attachments, I have shared the error that we are getting along with screenshot of properties of that pdf.

this is a critical incident for us, hence needs your highest attention on this.

thanks.

Aspose PDF Signature Issue

$
0
0

Hi Team,

                After generating the pdf with the help of Aspose.pdf 7.0 I am placing the signature into the pdf and save as a new pdf file once i open a saved pdf file the special charectores are getting damaged. any one can help me to come out with this issue.

Regards

Mohanasaravanan.

              

                   

Calculated form fields

$
0
0
I have an Acrobat pdf form that I want to use as a template.  This template has some calculated fields on it (see calculated tab in the properties of a form field in Acrobat Pro) that sets the value of the fields based on values from other fields on the page.  I want to know if, after using your product to update the form fields on the the template, will the calculated field have its value set (and formatted correctly based on the formating specified on the template for that field)?  We are converting an asp app to .net and are looking for a suitable replacement for the Adobe ActiveX FDF toolkit that currently use to do this stuff.

Aspose pdf and SharePoint online (Office 365)

$
0
0
Does the Aspose pdf converter works in Office 365 SharePoint Online?
I have a customer who wants to create pdf´s from list items, but it must be in the cloud (O365).

Unsupported font style when converting HTML to PDF

$
0
0
Hi I am having problem converting HTML string to PDF by using DOM approach.
Here's my sample code snippet.
license.SetLicense(lic_path);
string fullPath = "C:\\OutputFolder\\"
string emailBodyDetails = "<html><body><SPAN style=""FONT-FAMILY: Calibri, 'Segoe UI', Meiryo, 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', sans-serif; FONT-SIZE: 16px"">Content.</SPAN></body><html>";
using (FileStream fs = new FileStream(fullPath + "Output.html", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(emailBodyDetails);
}
fs.Close();
}
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(fullPath + "Output.html", new HtmlLoadOptions() { UseNewConversionEngine = true });
doc.Save(fullPath + "Output.pdf");

I am getting error during conversion, and I found out that the html font style Meiryo is causing it, as when I remove the style from the string, it works fine. May I know how can this font be included in my document conversion?

At the same time, can I know which font are not supported in Aspose and what can I do to ensure all types of fonts are supported because we are not able to control the style usage in html as those contents are coming in from emails.

Using Document() and PageInfo()

$
0
0
Need a little help trying to generate a PDF with a normal page size. When the PDF is created, it is really wide (like the equivalent of about 6-8 pages wide). I've tried forcing the page size by setting the PageInfo properties passed into HtmlLoadOptions, but it only appears to be effecting the height. I'd like to just force it to 8.5" x 11" with a landscape flag, but I'm not sure how to do it.

Here's how I'm building out the Document() object:

EDIT: Updated code snippets...

public string ConvertHtmlToPdf(string htmlString, string fileName, bool isLandscape = false, bool overwriteExisting = true)
{
    // Rename the file to a numbered copy if needed
    if (!overwriteExisting)
        fileName = GetUnusedFileName(fileName);

    // Get the full saved file path with name
    var fullPath = GetFullFilePath(fileName);

    // New up a document object
    var doc = GetBaseDocument(htmlString);

    var pdfSaveOptions = new PdfSaveOptions {WarningHandler = new HandleAsposeDocumentWarnings()};

    // Save the PDF file
    doc.Save(fullPath, pdfSaveOptions);

    return fileName;
}

private Document GetBaseDocument(string html, bool isLandscape = false)
{
    var htmlLoadOptions = new HtmlLoadOptions(_fileBasePath)
    {
        WarningHandler = new HandleAsposeDocumentWarnings()
    };

    // Convert string to stream to pass into the Document ctor
    var stream = new MemoryStream(Encoding.UTF8.GetBytes(html));
    var doc = new Document(stream, htmlLoadOptions)
    {
        OptimizeSize = true,
        PageInfo = GetBasePageInfo(isLandscape)
    };

    return doc;
}

private PageInfo GetBasePageInfo(bool isLandscape)
{
    return new PageInfo
    {
        IsLandscape = isLandscape,
        Margin = new Aspose.Pdf.MarginInfo
        {
            Top = 40,
            Bottom = 40,
            Left = 40,
            Right = 40
        }
    };
}

I should also note that I'm using bootstrap.css as my stylesheet. Are there some tricks to getting the styles to play nice with the PDF converter engine in order to get regular page sizes?

Also, is there a debug flag I can set somewhere so it will dump out errors into the PDF it creates? There are times when it doesn't display content at all, and messing with the HTML objects and classes can change that. I haven't figured out what's causing some elements to disappear some times.

Could not find any font linex

$
0
0
Hi Team,
My code works properly in Windows machine but when I run it on linex system, it says the fonts are not loaded.

I'm using aspose.pdf 9.5.0 version. I got upgraded from Aspose.Pdf.Kit.

I found a forum link which addressed similar issue but I don't find the suggested code relevant in my case - http://www.aspose.com/community/forums/thread/542072/could-not-find-any-font-error-on-linus.aspx

Also I see a couple of font related bugs you guys fixed (), but it does not make any difference in my case:
PDFNEWJAVA-33945 System default font should be used in case of missing fonts

Here is the stack trace.

com.aspose.pdf.internal.p233.z8: Could not find any font. Use Document.addLocalFontPath(String path) to set correct path for your fonts location.
at com.aspose.pdf.internal.p432.z16.m1(Unknown Source)
at com.aspose.pdf.internal.p432.z16.m8(Unknown Source)
at com.aspose.pdf.internal.p432.z16.m7(Unknown Source)
at com.aspose.pdf.internal.p432.z16.m1(Unknown Source)
at com.aspose.pdf.internal.p434.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p432.z29.m9(Unknown Source)
at com.aspose.pdf.internal.p432.z29.m21(Unknown Source)
at com.aspose.pdf.internal.p430.z13.m3(Unknown Source)
at com.aspose.pdf.internal.p430.z7.<init>(Unknown Source)
at com.aspose.pdf.internal.p430.z9.<init>(Unknown Source)
at com.aspose.pdf.internal.p430.z13.<init>(Unknown Source)
at com.aspose.pdf.internal.p429.z8.m1(Unknown Source)
at com.aspose.pdf.internal.p432.z29.m28(Unknown Source)
at com.aspose.pdf.internal.p432.z29.m1(Unknown Source)
at com.aspose.pdf.internal.p432.z31.m1(Unknown Source)
at com.aspose.pdf.internal.p434.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p433.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p434.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p434.z1.m2(Unknown Source)
at com.aspose.pdf.TextBoxField.m2(Unknown Source)
at com.aspose.pdf.WidgetAnnotation.m1(Unknown Source)
at com.aspose.pdf.Field.updateAppearances(Unknown Source)
at com.aspose.pdf.Field.m6(Unknown Source)
at com.aspose.pdf.Field.setValue(Unknown Source)
at com.aspose.pdf.TextBoxField.setValue(Unknown Source)
at com.aspose.pdf.facades.AForm.fillField(Unknown Source)
at com.aspose.pdf.facades.Form.fillField(Unknown Source)

Could you please suggest me something/workaround? Is this a known bug? 

Thanks,
Tvk Reddy

XSL-FO Font Naming Issue

$
0
0
Hi,

I have been using the Aspose.PDF library to render XSL-FO as a PDF but have encountered a Font Naming issue where the font cannot be found when printing.  In working with through the issue it was found that the /BaseFont value being stored in the PDF does not follow the PostScript naming schema.

Here is the documentation I found from the Adobe site:  http://partners.adobe.com/public/developer/en/font/5088.FontNames.pdf

Sec 2.2 mentions that the FontName generally consists of the family name followed by a hyphen and then styling attributes.

Given that info, if my XSL-FO element had a font-family="Arial" and a font-weight="bold" then the /BaseFont value in the PDF would be "Arial-Bold" (which works correctly) but when using the Aspose.Pdf.Generator.PDF::BindFO function the /BaseFont written out to the PDF is "ArialBold" which fails the font look up.

Here is the code i used to generate the PDF and attached is a sample xml:

global::Aspose.Pdf.Generator.Pdf oPdf = new global::Aspose.Pdf.Generator.Pdf();
oPdf.BindFO("Font.xml");
oPdf.Save("output.pdf");

This will create the following object in the PDF file:
<</Type/Font
/Subtype/TrueType
/FirstChar 0
/LastChar 255
/Widths[....]
/Encoding/WinAnsiEncoding
/BaseFont/ArialBoldItalic
/Name/ArialBoldItalic
/FontDescriptor 12 0 R
>>

If that value is updated to the following, then everything works correctly:
<</Type/Font
/Subtype/TrueType
/FirstChar 0
/LastChar 255
/Widths[....]
/Encoding/WinAnsiEncoding
/BaseFont/Arial-BoldItalic
/Name/ArialBoldItalic
/FontDescriptor 12 0 R
>>

Is there a way to change the value that is being stored in the /BaseFont field?

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

Converting Html with javascript to PDF

$
0
0
Hi All
i'm examine the html to PDF conversion and i'm trying to understand it is a license issue or the product is not meant for these king of conversion.
 
i have an html  uses knockout for databind from a separate javascript file .
the html also have referenced to css file for the html design 

when i'm trying to covert the html , none of the images are added to the PDF
the html css is not used ,also the binding is not working

thanks

 






IocContainer StructureMap Error

$
0
0
I have problems with aspose.pdf ans IocContainer StructureMap.

in forms applicatin I use "Business" Library
IocContainer is configured like this:

config.Scan(scanner =>
            {
                scanner.TheCallingAssembly();
                scanner.Assembly("Interface");

                //Here rais the error!!!!!!!!!!!!!!!!!!!
                scanner.Assembly("Business");
                scanner.LookForRegistries();

                scanner.WithDefaultConventions();
                scanner.LookForRegistries();
            });

My Bussiness looks like this:

namespace Business
{
    public class PdfManager : IPdfManager
    {
        private AsposeManager _asposeManager;
        public PdfManager()
        {
            _asposeManager = new AsposeManager();
        }

        public bool Create()
        {
            return _asposeManager.CreatePdf();
        }
    }
}

my extra lib PdfAspose is quit simble:

namespace PdfAspose
{
    public class AsposeManager 
    {
        public bool CreatePdf()
        {
            //uncomment and eror will rais
            var pdfConv = new Aspose.Pdf.Generator.Pdf();
            return true;
        }
    }
}

Build is with no error but runtime I get error on yellow:

file or assambly "Business" or a dependency not found....

if green line I comment out no error appear.

I would send a examble project-zip but upload give me a 

404 - File or directory not found.


Viewing all 3131 articles
Browse latest View live