mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
trim crappy characters
This commit is contained in:
parent
f227335e14
commit
8b039c61ed
@ -200,7 +200,7 @@ public class PdfUtil {
|
||||
.addText("Created by " + documentDto.getCreator()
|
||||
+ " on " + dateFormat.format(new Date(documentDto.getCreateTimestamp())), true)
|
||||
.newLine()
|
||||
.addText(Strings.nullToEmpty(documentDto.getDescription()).replaceAll("[\r\n]", ""))
|
||||
.addText(documentDto.getDescription())
|
||||
.newLine();
|
||||
if (!Strings.isNullOrEmpty(documentDto.getSubject())) {
|
||||
pdfPage.addText("Subject: " + documentDto.getSubject());
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.sismics.docs.core.util.pdf;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
import org.apache.pdfbox.pdmodel.font.PDFont;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Wrapper around PDFBox for high level abstraction of PDF writing.
|
||||
*
|
||||
@ -102,7 +102,10 @@ public class PdfPage implements Closeable {
|
||||
if (text == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Remove \r\n non breakable space
|
||||
text = text.replaceAll("[\r\n]", "").replace("\u00A0", " ");
|
||||
|
||||
pdContent.setFont(font, fontSize);
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
|
@ -251,14 +251,6 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertTrue(relations.getJsonObject(0).getBoolean("source"));
|
||||
Assert.assertEquals("My super title document 1", relations.getJsonObject(0).getString("title"));
|
||||
|
||||
// Export a document in PDF format
|
||||
Response response = target().path("/document/" + document1Id).request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
|
||||
.get();
|
||||
InputStream is = (InputStream) response.getEntity();
|
||||
byte[] pdfBytes = ByteStreams.toByteArray(is);
|
||||
Assert.assertTrue(pdfBytes.length > 0);
|
||||
|
||||
// Create a tag
|
||||
json = target().path("/tag").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
|
||||
@ -271,7 +263,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
|
||||
.post(Entity.form(new Form()
|
||||
.param("title", "My new super document 1")
|
||||
.param("description", "My new super description for document 1")
|
||||
.param("description", "My new super description for document\r\n\u00A0 1")
|
||||
.param("subject", "My new subject for document 1")
|
||||
.param("identifier", "My new identifier for document 1")
|
||||
.param("publisher", "My new publisher for document 1")
|
||||
@ -291,7 +283,15 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
.param("title", "My super title document 2")
|
||||
.param("language", "eng")), JsonObject.class);
|
||||
Assert.assertEquals(document2Id, json.getString("id"));
|
||||
|
||||
|
||||
// Export a document in PDF format
|
||||
Response response = target().path("/document/" + document1Id).request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, document1Token)
|
||||
.get();
|
||||
InputStream is = (InputStream) response.getEntity();
|
||||
byte[] pdfBytes = ByteStreams.toByteArray(is);
|
||||
Assert.assertTrue(pdfBytes.length > 0);
|
||||
|
||||
// Search documents by query
|
||||
json = target().path("/document/list")
|
||||
.queryParam("search", "new")
|
||||
|
Loading…
Reference in New Issue
Block a user