Questions about Aspose Total for .NET/Java and both

Which point is not covered, please mention.

@praveen043

Your No 4. Please see License Types - Purchase - aspose.com for full details.

Kind regards,

George.

After POM entry

com.aspose aspose-pdf 18.5

taking approx. 10 min to start the tomcat server.

@praveen043

Would you please try your scenario with Aspose.PDF for Java 18.7 as it is always recommended to use latest version. In case issue still persists, please let us know by sharing a sample application which is able to replicate the issue in any environment. We will test the scenario in our environment and address it accordingly.

Hello team,
I have used the following jar files to water marking-
1, aspose-pdf-18.5.jar
2. aspose-slides-16.6.0.jar
3. aspose-cells-16.10.0.jar
to put the confidential water marking but i am worried from output.

  1. In PDF file, no water marking has displayed
  2. In PPT, it is not giving any desired result.
  3. In excel, anybody can delete/change the watermarking applied from the source code.

Also, it’s taking too much time to execute it. Please provide me the correct jar files and source code for watermarking (pdf, excel, ppt, word and image).Excel.png (122.2 KB)
PDF.png (125.3 KB)
PPT.png (130.9 KB)

@praveen043,

Thanks for the screenshots and details.

Regarding MS Excel watermark, you may lock the word art shape, see the following lines of code that you may add before saving the spreadsheet, it will work for your needs:
e.g
Sample code:

..............
// Lock Shape Aspects
	wordart.setLocked(true);
	wordart.setLockedProperty(ShapeLockType.SELECTION, true);
	wordart.setLockedProperty(ShapeLockType.SHAPE_TYPE, true);
	wordart.setLockedProperty(ShapeLockType.MOVE, true);
	wordart.setLockedProperty(ShapeLockType.RESIZE, true);
	wordart.setLockedProperty(ShapeLockType.TEXT, true);

Regarding your issues with PDF and PPT file formats, we will check and get back to you soon.

@praveen043

We have checked the shared screenshot of PDF document and code snippet used for watermarking it. We request you to please remove/comment following line of code which is stopping watermark text to be displayed in the document:

textStamp.setBackground(true);

Setting the background property as true means the stamp would be rendered beneath the layer of original content and would not be visible. Also, please ensure to set license for each API separately in your application before using their features.

As shared earlier, please use latest version of the API i.e. Aspose.PDF for Java 18.7, as it contains more enhancements and improvements. In case you are still unable to achieve the desired results, please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.

@praveen043,

And, regarding PPT file format issue, kindly try our latest version/fix: Aspose.Slides v18.7, it should fix your issue.

Let us know if you still have any issue.

Please provide the Watermarking java source code for image files.

Water mark not working at all pages. Please refer the below source code–

private static void insertWatermarkText(Document doc, String watermarkText) throws Exception

{

// Create a watermark shape. This will be a WordArt shape.

// You are free to try other shape types as watermarks.

Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);

// Set up the text of the watermark.

watermark.getTextPath().setText(watermarkText);

watermark.getTextPath().setFontFamily( "Arial" );

watermark.setWidth( 500 );

watermark.setHeight( 100 );

// Text will be directed from the bottom-left to the top-right corner.

watermark.setRotation(- 40 );

// Remove the following two lines if you need a solid black text.

watermark.getFill().setColor(Color.GRAY); // Try LightGray to get more Word-style watermark

watermark.setStrokeColor(Color.GRAY); // Try LightGray to get more Word-style watermark

// Place the watermark in the page center.

watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);

watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);

watermark.setWrapType(WrapType.NONE);

watermark.setVerticalAlignment(VerticalAlignment.CENTER);

watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

// Create a new paragraph and append the watermark to this paragraph.

Paragraph watermarkPara = new Paragraph(doc);

watermarkPara.appendChild(watermark);

// Insert the watermark into all headers of each document section.

for (Section sect : doc.getSections())

{

// There could be up to three different headers in each section, since we want

// the watermark to appear on all pages, insert into all headers.

insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_PRIMARY);

// insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_FIRST);

// insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_EVEN);

}

}

private static void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, int headerType) throws Exception

{

HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);

if (header == null )

{

// There is no header of the specified type in the current section, create it.

header = new HeaderFooter(sect.getDocument(), headerType);

sect.getHeadersFooters().add(header);

}

// Insert a clone of the watermark into the header.

header.appendChild(watermarkPara.deepClone( true ));

}

@praveen043,

For your following requirements:

    private void StampWatermarkOnRaster(Image image)
    {
        int watermarkWidth = 230;
        int watermarkHeight = 50;
        Font watermarkFont = new Font("Arial", 10);
        Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush();
        brush.Color = Color.Black;
        Pen pen = new Pen(Color.Red, 2);
        Aspose.Imaging.Brushes.SolidBrush backBrush = new Aspose.Imaging.Brushes.SolidBrush(Color.White);

        // simple raster watermarking
        Graphics graphics = new Graphics(image);
        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
        if (watermarkHeight < image.Height && watermarkWidth < image.Width)
        {
            graphics.FillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
            graphics.DrawString(EvaluationMessage, watermarkFont, brush, new Aspose.Imaging.PointF(0, 0));
        }
        else
        {
            graphics.DrawLine(pen, 0, 0, image.Width - 1, image.Height - 1);
            graphics.DrawLine(pen, image.Width - 1, 0, 0, image.Height - 1);
        }
    }

This is java code “Aspose.Imaging.Brushes.SolidBrush”?

@praveen043,

Please try using following Java code on your end to serve the purpose.

private void StampWatermarkOnRaster(Image image)
{
    int watermarkWidth = 230;
    int watermarkHeight = 50;
    Font watermarkFont = new Font("Arial", 10);
    com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush();
    brush.setColor(Color.getBlack());
    Pen pen = new Pen(Color.getRed(), 2);
    com.aspose.imaging.brushes.SolidBrush backBrush = new com.aspose.imaging.brushes.SolidBrush(Color.getWhite());

    // simple raster watermarking
    Graphics graphics = new Graphics(image);
    graphics.setTextRenderingHint(TextRenderingHint.SingleBitPerPixelGridFit);
    if (watermarkHeight < image.getHeight() && watermarkWidth < image.getWidth())
    {
        graphics.fillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
        graphics.drawString("EvaluationMessage", watermarkFont, brush, new com.aspose.imaging.PointF(0, 0));
    }
    else
    {
        graphics.drawLine(pen, 0, 0, image.getWidth() - 1, image.getHeight() - 1);
        graphics.drawLine(pen, image.getWidth() - 1, 0, 0, image.getHeight() - 1);
    }
}

We have change the code it’s working. But i have not got the appropriate output as per our requirement. Same problem with PPT also.

Please find the attached document for the same.new_change_201884_2323.jpeg (66.8 KB)
PPT.png (130.9 KB)

@praveen043

Would you please share your sample input files (i.e. Source Image and PPT) with us. We will test the scenario in our environment and address it accordingly.

Please find the attached sample file and source codeCapture.png (2.9 KB)
B.zip (22.3 KB)

PPT–

com.aspose.slides.Presentation pres = new com.aspose.slides.Presentation(path + fileName);
com.aspose.slides.IMasterSlide master = pres.getMasters().get_Item(0);
com.aspose.slides.IAutoShape ashp = master.getShapes().addAutoShape(
com.aspose.slides.ShapeType.Rectangle, 10, 10, 300, 300);
ashp.addTextFrame(“Confidential”);
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions()
.get_Item(0).getPortionFormat().setFontHeight(25);
master.getShapes().reorder(0, ashp);
ashp.getAutoShapeLock().setSelectLocked(true);
ashp.getAutoShapeLock().setSizeLocked(true);
ashp.getAutoShapeLock().setTextLocked(true);
ashp.getAutoShapeLock().setPositionLocked(true);
ashp.getAutoShapeLock().setGroupingLocked(true);

	pres.save(path + "confidentieldata\\" + fileName,
			com.aspose.slides.SaveFormat.Pptx);

Image—

com.aspose.imaging.Image image = com.aspose.imaging.Image.load(path+fileName);

int watermarkWidth = 230;
int watermarkHeight = 50;
com.aspose.imaging.Font watermarkFont = new com.aspose.imaging.Font(“Arial”, 10);
com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush();
brush.setColor(com.aspose.imaging.Color.getBlack());
com.aspose.imaging.Pen pen = new com.aspose.imaging.Pen(com.aspose.imaging.Color.getRed(), 2);
com.aspose.imaging.brushes.SolidBrush backBrush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getWhite());

    // simple raster watermarking
    com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(image);
    graphics.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixelGridFit);
    if (watermarkHeight < image.getHeight() && watermarkWidth < image.getWidth())
    {
        graphics.fillRectangle(backBrush, 0, 0, watermarkWidth, watermarkHeight);
        graphics.drawString("Confidential", watermarkFont, brush, new com.aspose.imaging.PointF(0, 0));
    }
    else
    {
        graphics.drawLine(pen, 0, 0, image.getWidth() - 1, image.getHeight() - 1);
        graphics.drawLine(pen, image.getWidth() - 1, 0, 0, image.getHeight() - 1);
    }

    image.save(path + "confidentieldata\\" + fileName);

@praveen043,

Can you please share the details of issue incurring on your end. Please share the details so that I may help you further in this regard.

The water marking not working on PPT and image file. It’s showing evaluation copy right of company tool.

@praveen043,

I suggest you to please try using Aspose.Slides license to avoid evaluation watermark and setting watermark. For your further reference, please visit this documentation link.

A post was split to a new topic: Quotation for Aspose.Total for Java